package com.mojo.proxy;

/**
 * 静态代理代码示例
 *
 * @author <a href="mailto:sjj@jianzhimao.com">mojo</a>
 * copyright (C), 2013-2022, 广州九尾信息科技有限公司
 * @date 2022/3/4 10:45
 */
public class StaticProxy {
    public static void main(String[] args) {
        ProxySubject subject = new ProxySubject(new RealSubject());
        subject.m();
    }
}

interface Subject {
    void m();
}

class RealSubject implements Subject {

    @Override
    public void m() {
        System.out.println("真实实现对象");
    }
}

class ProxySubject implements Subject {


    private RealSubject realSubject;

    public ProxySubject(RealSubject realSubject) {
        this.realSubject = realSubject;
    }

    @Override
    public void m() {
        realSubject.m();
        System.out.println("代理实现对象");
    }
}